TIP FOR JANUARY 1996

This is a monthly segment in which Versant Object Technology touches upon some aspect of object databases. This month's tip focuses on Persistence in general.

PERSISTENCE IN VERSANT

First, Happy New Year!

Because there has been some confusion between what is a persistent object and what is a transient object, this month's tip is more of a small lesson on the topic rather than just a programming tip. In C++, in order to make your objects persistent, your class definition must inherit from a base class called PObject . This makes the class "persistent capable." Persistence through inheritance is a concept endorsed by the ODMG.

Note that this does not necessarily make an object persistent upon simple instantiation.The object will be created as a transient object if the standard new operator is used even though the class inherits from PObject . To make your object persistent, in the compiler independent way of doing things in Versant in a heterogenous environment, you can use the following macro for your convenience. (There are a couple of other ways of doing this not covered here). The simple example takes no parameters for the constructor.

Class *my_var = O_NEW_PERSISTENT(Class)();

Provided that this instantiation is used within a transaction and the transaction is committed, this will make the object persistent. You can call the PObject method is_persistent() to ask an object if it is persistent.

In Smalltalk, the issue is a little bit different, but the concept remains the same. Basic Smalltalk provides persistence for images in the form of snapshots, filein's, and BOSS files. However, this does not support distribution, concurrency, and transaction management which are all database concepts.That's the business of object databases.

As you may know, in basic Smalltalk, all objects inherit from a base object already. What Versant provides is transparent creation and access for these objects to and from an object database. You use your native Smalltalk environment to make your application. When objects are created, they are transient. To make an object persistent, you have to call the becomePersistent method on that object.

PERSISTENCE AND TRANSIENCE

What we have learned here is that just because an object is capable of becoming persistent does not necessarily mean that we want to make it persistent. The needs of the application should provide guidance concerning when to store an object in a database and when to create a transient instance of an object.

Objects which represent data or contain data which is to be retrieved after the creator application ends, or information to be shared through other users, should be placed in a database. Objects which represent complex computational objects or Graphical User Interface (GUI) components usually should not be made persistent.

These are simple rules, but again the requirements of the software will arbitrate the decisions.

by Nimish Doshi


[ What's New | Products | Partners | Tech Support | About Us | Employment | Contact Us | Search | Home ]
[ C++ Solutions | SmallTalk Solutions | Internet Solutions ]

©1996 Versant Object Technology
1380 Willow Road
Menlo Park, CA 94025
USA

1-800-VERSANT
Tel 415-329-7500
Fax 415-325-2380
e-mail info@versant.com